//
//  ADSelector.h
//  ADKit
//
//  Created by duzexu on 2018/4/4.
//  Copyright © 2018年 duzexu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ADAccessoryView : UIToolbar

@property (nonatomic, strong) UILabel *titleLabel;

@end

typedef NS_ENUM(NSInteger, ADSelectorType) {
    ADSelectorTypeNormal, //普通选择
    ADSelectorTypeDate //日期选择
};

@class ADSelector;
@protocol ADSelectorDelegate <NSObject>

@optional
- (void)selector:(ADSelector *)selector didSelect:(id)value;
- (void)selectorDidCancel:(ADSelector *)selector;

@end

@interface ADSelectorItem : NSObject

@property (nonatomic, copy) NSString *value;
@property (nonatomic, strong) id ext;
@property (nonatomic, strong) NSArray<ADSelectorItem *> *subItems;

@property (nonatomic, assign) BOOL isEnd;
@property (nonatomic, assign) BOOL isVaild;

@end

@interface ADSelectorConfig : NSObject

@property (nonatomic, assign) CGFloat accessoryViewHeight;
@property (nonatomic, strong) UIColor *accessoryViewColor;
@property (nonatomic, copy) NSString *accessoryCancelTitle;
@property (nonatomic, strong) UIFont *accessoryCancelFont;
@property (nonatomic, strong) UIColor *accessoryCancelColor;
@property (nonatomic, copy) NSString *accessoryConfirmTitle;
@property (nonatomic, strong) UIFont *accessoryConfirmFont;
@property (nonatomic, strong) UIColor *accessoryConfirmColor;
@property (nonatomic, strong) UIFont *accessoryTitleFont;
@property (nonatomic, strong) UIColor *accessoryTitleColor;
@property (nonatomic, assign) CGFloat pickerViewHeight;
@property (nonatomic, assign) CGFloat pickerViewRowHeight;
@property (nonatomic, strong) UIFont *pickerRowFont;
@property (nonatomic, strong) UIColor *pickerRowColor;

+ (instancetype)sharedConfig;

@end

@interface ADSelector : NSObject

@property (nonatomic, weak) id<ADSelectorDelegate> delegate;

@property (nonatomic, readonly, assign) ADSelectorType selectorType;

@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) ADAccessoryView *accessoryView;

//normal
@property (nonatomic, readonly, strong) NSArray<ADSelectorItem *> *dataSource;
@property (nonatomic, strong) NSArray *defaultIndexs;

//date
@property (nonatomic, strong) NSDate *minDate;      //enabled min date range.
@property (nonatomic, strong) NSDate *maxDate;      //enabled max date range.
@property (nonatomic, strong) NSDate *defaultDate;

//result
@property (nonatomic, strong) id value;

- (instancetype)initWithTitle:(NSString *)title dataSource:(NSArray<ADSelectorItem *> *)datasource selectorType:(ADSelectorType)type NS_DESIGNATED_INITIALIZER;

- (void)showInView:(UIView *)view;

@end
